package com.atguigu.tingshu.account.api;

import com.atguigu.tingshu.account.service.RechargeInfoService;
import com.atguigu.tingshu.common.anno.GuiguLogin;
import com.atguigu.tingshu.common.result.Result;
import com.atguigu.tingshu.model.account.RechargeInfo;
import com.atguigu.tingshu.vo.account.RechargeInfoVo;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.HashMap;
import java.util.Map;

@Tag(name = "充值管理")
@RestController
@RequestMapping("api/account/rechargeInfo")
@SuppressWarnings({"unchecked", "rawtypes"})
public class RechargeInfoApiController {

	@Autowired
	private RechargeInfoService rechargeInfoService;


	@GuiguLogin
	@PostMapping(value = "/submitRecharge")
	public Result<Map<String , String>> submitRecharge(@RequestBody RechargeInfoVo rechargeInfoVo) {
		String orderNo = rechargeInfoService.submitRecharge(rechargeInfoVo) ;
		Map<String , String> result = new HashMap<>() ;
		result.put("orderNo" , orderNo) ;
		return Result.ok(result) ;
	}

	@GetMapping(value = "/findRechargeInfoByOrderNo/{orderNo}")
	public Result<RechargeInfo> findRechargeInfoByOrderNo(@PathVariable(value = "orderNo") String orderNo) {
		RechargeInfo rechargeInfo = rechargeInfoService.findRechargeInfoByOrderNo(orderNo) ;
		return Result.ok(rechargeInfo) ;
	}

}

